package com.jiujiu.model;

import com.alibaba.fastjson.JSONObject;
import com.jiujiu.MustInterface.JiuJiuAnalysis;
import com.jiujiu.model.DataBaseCommon.SqlEntity;
import com.jiujiu.utitls.ContentMap;
import com.jiujiu.utitls.SqlDriver;

import java.util.List;

/**
 * @author ZhaoJunZhou
 * @Date 2020/11/4
 */
public class DataBaseToJava implements JiuJiuAnalysis {
    @Override
    public void analysis(JSONObject jsonObject) {
        List<SqlEntity> sqlEntities = jsonObject.getJSONArray("sqls").toJavaList(SqlEntity.class);
        SqlDriver.iniDriverManager(
                jsonObject.getString("url"),
                jsonObject.getString("driverClassName"),
                jsonObject.getString("username"),
                jsonObject.getString("password")
        );
        for (SqlEntity sqlEntity : sqlEntities) {
            SqlDriver.executeSql(sqlEntity);
        }
    }
}
